<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
	exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


  <xsl:output method="html" omit-xml-declaration="yes" />

  <xsl:param name="currentPage"/>

  <!-- Input the documenttype you want here -->
  <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
  <!-- Use div elements around this macro combined with css -->
  <!-- for styling the navigation -->
  <xsl:variable name="level" select="1"/>

  <xsl:template match="/">

    <!-- The fun starts here -->

    <nav class="main">
      <ul>
        <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=$level]">
          <xsl:if test="./data[@alias='footerMenu'] != '1' and ./data[@alias='umbracoNaviHide'] != '1'">
            <li>
              <xsl:if test="$currentPage/@id = current()/@id">
                <xsl:attribute name="class">
                  <xsl:text>active</xsl:text>
                </xsl:attribute>
              </xsl:if>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
              <span>
                by  <xsl:value-of select="@nodeName"/>
              </span>
            </li>
          </xsl:if>
          <xsl:call-template name="buildMenu">
            <xsl:with-param name="node" select="." />
          </xsl:call-template>
        </xsl:for-each>
      </ul>
    </nav>
  </xsl:template>

  <xsl:template name="buildMenu">
    <xsl:param name="node" />

    <xsl:for-each select="$node/descendant::node[@level=2]">
      <xsl:if test="./data[@alias='footerMenu'] != '1' and ./data[@alias='umbracoNaviHide'] != '1'">
        <li>
          <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
            <xsl:attribute name="class">
              <xsl:text>active</xsl:text>
            </xsl:attribute>
          </xsl:if>
          <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/>
          </a>
          <span>
            by  <xsl:value-of select="@nodeName"/>
          </span>
        </li>
      </xsl:if>
    </xsl:for-each>

  </xsl:template>

</xsl:stylesheet>